package com.stlm2.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by songfangyuan on 2017/2/27.
 */
public class DbUtil {
      public static SqlSessionFactory sqlSessionFactory;
    public DbUtil(){
        //读取配置文件
        if(sqlSessionFactory==null){
            try {

                InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
                //初始化mybatis,创建SqlSessionFactory类的实例
                sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
              
            } catch (IOException e) {
                e.printStackTrace();
            }
        }



    }
}
